package org.sdp.pearproject.service.impl;


import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;
import org.sdp.pearproject.dao.domain.*;
import org.sdp.pearproject.service.*;
import org.sdp.pearproject.service.custom.*;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

/**
 * @ClassName: TaskStagesTemplateServiceImpl
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-21
 * @Version: 1.0
 * Table: pear_task_stages_template
 * Comment:
 * 任务列表模板表
 */
@Service
public class TaskStagesTemplateServiceImpl extends TaskStagesTemplateServiceCustomImpl implements TaskStagesTemplateService {

    static {
        beanClassNameMap.put("task_stages_template", "taskStagesTemplateServiceImpl");
        listMethodNameMap.put("task_stages_template", "listTaskStagesTemplate");
        listMethodParameterClassNameMap.put("task_stages_template", "TaskStagesTemplateQueryRequest");
        updateMethodNameMap.put("task_stages_template", "updateTaskStagesTemplate");
        updateMethodParameterClassNameMap.put("task_stages_template", "TaskStagesTemplateUpdateRequest");
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer addTaskStagesTemplate(TaskStagesTemplateAddRequest request) throws Exception {
        super.fixRequest("task_stages_template", "add", request);
        return super.addTaskStagesTemplate(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer updateTaskStagesTemplate(TaskStagesTemplateUpdateRequest request) throws Exception {
        TaskStagesTemplate record = null;
        record = taskStagesTemplateMapper.selectByPrimaryKey(request.getId());
        super.fixRequest("task_stages_template", "update", request, record);
        return super.updateTaskStagesTemplate(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer deleteTaskStagesTemplate(TaskStagesTemplateDeleteRequest request) throws Exception {
        if (needCheckDeleteList(request)) {
            List<TaskStagesTemplate> list = null;
            TaskStagesTemplateExample example = new TaskStagesTemplateExample();
            example.createCriteria().andIdIn(request.getIdList());
            list = taskStagesTemplateMapper.selectByExample(example);
            fixRequest("task_stages_template", "delete", request, list);
        } else {
            fixRequest("task_stages_template", "delete", request);
        }
        return super.deleteTaskStagesTemplate(request);
    }

    @Override
    public TaskStagesTemplateQueryResponse queryTaskStagesTemplate(TaskStagesTemplateQueryRequest request) throws Exception {
        super.checkNonNull(request.getId(), "id");
        TaskStagesTemplateQueryResponse result = super.queryTaskStagesTemplate(request);
        checkResult("task_stages_template", "query", request, result);
        return result;
    }

    @Override
    public List<TaskStagesTemplateQueryResponse> listTaskStagesTemplate(TaskStagesTemplateQueryRequest request) throws Exception {
        List<TaskStagesTemplateQueryResponse> list = super.listTaskStagesTemplate(request);
        checkResult("task_stages_template", "list", request, list);
        return list;
    }

    @Override
    public Integer countTaskStagesTemplate(TaskStagesTemplateQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("task_stages_template", "count", request);
        return super.countTaskStagesTemplate(request);
    }

    @Override
    public BaseStatResponse statTaskStagesTemplate(TaskStagesTemplateQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("task_stages_template", "stat", request);
        return super.statTaskStagesTemplate(request);
    }

}
